﻿package base
{
    import com.dusk.tool.ColorMatrix;
    import com.dusk.tool.HitTest;
    import com.dusk.util.McUtil;
    import com.dusk.util.RandomUtil;
    import com.dusk.util.ResUtil;
    import com.dusk.util.UtilBase;
    import com.game.data.constant.HitType;
    import com.game.data.vo.GameGadgetVO;
    import com.game.data.vo.HitResultVO;
    import com.game.data.vo.HitVO;
    import com.game.data.vo.PetDataVO;
    import com.game.event.GameEventType;
    import com.game.manager.EventManager;
    import com.game.view.component.GameGadgetType;
    import com.greensock.TweenMax;
    
    import export.bullet.*;
    
    import flash.display.*;
    import flash.events.*;
    import flash.filters.*;
    import flash.geom.*;
    
    public class BasePet extends BaseObject
    {
        
        public function BasePet(param1:BaseHero, param2:PetDataVO)
        {
            skillCD1 = [-1, 30];
            skillCD2 = [-1, 30];
            skillCD3 = [-1, 30];
            skillCD4 = [-1, 30];
            super();
            _petInfo = param2;
            sourceRole = param1;
            newHpSlip();
            jumpPower = -30;
            curAddEffect = new BaseAddEffect(BaseObject(this));
            bbdc.turnRight();
            curAddEffect.addEffects([{
                "name": "father",
                "time": gc.frameClips * 5,
                "interval": 1000,
                "isForever": 1
            }]);
            horizonSpeed = _petInfo.moveSpeed;
        }
        
        protected var sourceRole:BaseHero;
        protected var _petInfo:PetDataVO;
        
        protected var attackRate:Number = 0.7;
        
        protected var attackRange:uint = 150;
        
        protected var searchRange:uint = 400;
        
        protected var followRange:uint = 200;
        
        protected var curAttackTarget:BaseObject;
        
        protected var lastBeAttackedTarget:BaseObject;
        
        protected var skillCD1:Array;
        
        protected var skillCD2:Array;
        
        protected var skillCD3:Array;
        
        protected var skillCD4:Array;
        
        protected var timeCount:uint = 0;
        
        protected var sxkbCount:uint = 300;
        
        protected var fsnlCount:uint = 300;
        
        protected var smjcCount:uint = 300;
        
        protected var mfjcCount:uint = 300;
        
        protected var gjjcCount:uint = 300;
        
        protected var fyjcCount:uint = 300;
        
        protected var testCount:uint = 96;
        
        protected var tCount:uint = 0;
        private var hpSlip:Sprite;
        
        override protected function initBBDC():void
        {
        }
        
        override public function step():void
        {
            var _loc1_:* = null;
            var _loc2_:* = [];
            for each (_loc1_ in magicBulletArray)
            {
                _loc1_.step2();
                if (_loc1_.isReadyToDestroy)
                {
                    _loc2_.push(_loc1_);
                }
            }
            if (tCount++ >= gc.frameClips)
            {
                doPassive();
                tCount = 0;
            }
            clearWaitFromParentArray(_loc2_, magicBulletArray);
            myIntelligence();
            _petInfo.upPassive();
            countSkillCD();
            ++timeCount;
            if (timeCount >= 59999)
            {
                timeCount = 0;
            }
            if (isGXP)
            {
                if (Number(timeCount) % 4 == 0)
                {
                    McUtil.shallowEffect(this);
                }
            }
            if (AUtils.GetDisBetweenTwoObj(this, sourceRole) >= 800)
            {
                if (!isAttacking() && !isBeAttacking())
                {
                    x = sourceRole.x;
                    y = Number(sourceRole.y) - 30;
                }
            }
            super.step();
        }
        
        override protected function move():void
        {
            if (curAddEffect)
            {
                if (curAddEffect.isCannotControlSkill())
                {
                    setStatic();
                    return;
                }
            }
            super.move();
        }
        
        override public function beMagicAttack(param1:BaseBullet, param2:BaseObject, param3:Boolean = false):Boolean
        {
            return super.beMagicAttack(param1, param2, param3);
            /*var atkBackInfoDict:Object = {};
            var _loc5_:int = 0;
            var _loc9_:* = null;
            var singleAddEffect:Object;
            var _loc16_:Boolean = false;
            if (isInvincible())
            {
                return false;
            }
            if (param3 || checkCollideTarget(param1))
            {
                if (getCurAddEffect(BaseAddEffect.PET_RABBIT_MISS))
                {
                    var petState:int = int(_petInfo.petName.charAt(_petInfo.petName.length - 1));
                    if (Math.random() < 0.1 + petState * 0.1)
                    {
                        _loc16_ = true;
                    }
                }
                if (RandomUtil.randBoolean(getMiss() - param2.getHit()))
                {
                    _loc16_ = true;
                }
                if (_loc16_)
                {
                    addMissMc();
                    return true;
                }
                if (param1.hitVO.isBingo)
                {
                    var vo:GameGadgetVO = new GameGadgetVO(GameGadgetType.BINGO, new Point(x, y));
                    EventManager.getIns().dispatchEvent(GameEventType.ADD_GAME_GADGET, vo);
                    setInvincible(gc.frameClips * 2);
                    reduceHp(getHpMax() * 0.55);
                    return false;
                }
                lastBeAttackedTarget = param2;
                curAttackTarget = param2;
                atkBackInfoDict = param2.attackBackInfoDict[param1.curAction];
                if (atkBackInfoDict)
                {
                    _loc9_ = getAttackBackSpeed(param1, new HitVO());
                    if (param1.getBulletName() != "Role1Bullet12" && curAddEffect.getBuffByName(BaseAddEffect.STEEL_BODY) == null)
                    {
                        setAttackBack(_loc9_);
                    }
                    if (atkBackInfoDict.addEffect)
                    {
                        var addEffectClone:Array = UtilBase.clone(atkBackInfoDict.addEffect) as Array;
                        for each (singleAddEffect in addEffectClone)
                        {
                            if (singleAddEffect.time == BaseBullet.DESIDE_BY_FRAMES_LEFT)
                            {
                                singleAddEffect.time = param1.getFrameLeft();
                            }
                        }
                        addCurAddEffect(addEffectClone);
                    }
                }
                isCrit = param1.isCrit;
                _loc5_ = param2.getRealPower(param1.curAction, false);
                _loc5_ = countHurt(_loc5_, param2.getDeMagicDef(), atkBackInfoDict);
                /!*if (param2 is Monster6)
                {
                    if (Math.random() <= 0.1)
                    {
                        if (curAddEffect)
                        {
                            curAddEffect.add([{
                                "name": BaseAddEffect.PETHORSE_ICE,
                                "time": gc.frameClips * 1.5
                            }]);
                        }
                    }
                }
                else if (param2 is Monster16)
                {
                    if (Math.random() <= 0.2)
                    {
                        if (curAddEffect)
                        {
                            curAddEffect.add([{
                                "name": BaseAddEffect.PETMONKEY_FIRE,
                                "hurt": 10,
                                "time": gc.frameClips * 3
                            }]);
                        }
                    }
                }*!/
                if (param1.getBulletName() == "Role1Bullet12")
                {
                    reduceHp(_loc5_);
                }
                else
                {
                    reduceHp(_loc5_);
                }
                addBeAttackEffect(param2);
                return true;
            }
            return false;*/
        }
        
        override public function setAttackBack(param1:Point):void
        {
            if (!isGXP)
            {
                super.setAttackBack(param1);
            }
        }
        
        override protected function getDownStair():void
        {
            if (Boolean(standInObj) && Boolean(standInObj.getChildByName("isThroughWall")))
            {
                y += 20;
            }
        }
        
        override public function reduceHp(value:int = 0):void
        {
            var _loc4_:Number = Number(NaN);
            showHpSlip();
            _petInfo.reduceHp(value);
            drawPetHp();
            if (getHp() <= 0)
            {
                if (curAction != "dead")
                {
                    setInvincible(gc.frameClips * 5);
                    setAction("dead");
                    _petInfo.lifetime--;
                }
            }
            else if (false)
            {
                if (_petInfo.findHasStudySkill("qlfj"))
                {
                    _loc4_ = Number(_petInfo.getPetHarmObj("qlfj").first);
                    if (Math.random() <= _loc4_)
                    {
                        if (!isAttacking())
                        {
                            setInvincible(gc.frameClips);
                            normalHit();
                        }
                    }
                    setAction("hurt");
                    return;
                }
                setAction("hurt");
            }
        }
        
        override protected function addBeAttackEffect():void
        {
            var _loc2_:MovieClip = ResUtil.getNewObj("HeroBeHurt");
            var _loc3_:ColorMatrix = new ColorMatrix();
            _loc3_.adjustColor(0, 0, 0, 100);
            _loc2_.filters = [new ColorMatrixFilter([_loc3_])];
            addChild(_loc2_);
        }
        
        override protected function jump():void
        {
            if (velocity.y >= 0)
            {
                velocity.y = jumpPower;
            }
        }
        
        override public function getRealPower(param1:String, param2:Boolean = true):int
        {
            switch (param1)
            {
                case "hit1":
                    return 10;
                default:
                    return 0;
            }
        }
        
        override public function isDead():Boolean
        {
            return getHp() <= 0;
        }
        
        override public function getHp():int
        {
            return _petInfo.hp;
        }
        
        override public function getHpMax():int
        {
            return _petInfo.hpMax;
        }
        
        override public function getMp():int
        {
            return _petInfo.mp;
        }
        
        override public function getMpMax():int
        {
            return _petInfo.mpMax;
        }
        
        override public function getAtk():int
        {
            return _petInfo.atk;
        }
        
        override public function getDef():int
        {
            return _petInfo.def;
        }
        
        override public function getCrit():int
        {
            return _petInfo.crit;
        }
        
        override public function getMagicDef():int
        {
            return _petInfo.magicDef;
        }
        
        override public function getMiss():int
        {
            return _petInfo.miss;
        }
        
        override public function getCritDamage():int
        {
            return _petInfo.critDamage;
        }
        
        override public function getDeCritDamage():int
        {
            return _petInfo.deCritDamage;
        }
        
        override public function cureHp(value:int = 0):void
        {
            if (isDead())
            {
                return;
            }
            super.cureHp(value);
            _petInfo.cureHp(value);
        }
        
        public function setPetInfo(param1:PetDataVO):void
        {
            _petInfo = param1;
        }
        
        public function turnToGxp(param1:uint):void
        {
            var time:uint = param1;
            isGXP = true;
            horizonSpeed = 10;
            TweenMax.delayedCall(time, function (param1:BasePet):*
            {
                param1.cancelGxp();
            }, [this]);
        }
        
        public function cancelGxp():void
        {
            isGXP = false;
            horizonSpeed = 5;
        }
        
        public function setOtherAction(param1:String):void
        {
            switch (param1)
            {
                case "idle":
                    setAction("idle");
                    setStatic();
                    break;
                case "jump":
                    jump();
                    break;
                case "turnLeft":
                    turnLeft();
                    setAction("walk");
                    break;
                case "turnRight":
                    turnRight();
                    setAction("walk");
                    break;
                case "getfalldown":
                    getDownStair();
            }
        }
        
        override public function cureMp(value:int = 0):void
        {
            if (isDead())
            {
                return;
            }
            _petInfo.cureMp(value);
        }
        
        public function getPetData():PetDataVO
        {
            return _petInfo;
        }
        
        public function addPetHurtMc(vo:HitResultVO):void
        {
            var gadgetVO:GameGadgetVO = new GameGadgetVO();
            gadgetVO.value = vo.hurt;
            gadgetVO.position = new Point(x, getCollideArea().top);
            switch (vo.hitType)
            {
                case HitType.PHYSICS:
                    gadgetVO.type = vo.isCrit ? GameGadgetType.NUM_HERO_CRIT_HURT_PHYSICS : GameGadgetType.NUM_HERO_HURT_PHYSICS;
                    break;
                case HitType.MAGIC:
                    gadgetVO.type = vo.isCrit ? GameGadgetType.NUM_HERO_CRIT_HURT_MAGIC : GameGadgetType.NUM_HERO_HURT_MAGIC;
                    break;
                case HitType.REAL:
                    gadgetVO.type = vo.isCrit ? GameGadgetType.NUM_HERO_CRIT_HURT_REAL : GameGadgetType.NUM_HERO_HURT_REAL;
                    break;
            }
            EventManager.getIns().dispatchEvent(GameEventType.ADD_GAME_GADGET, gadgetVO);
        }
        
        public function faceToTarget():void
        {
            if (curAttackTarget)
            {
                if (x < curAttackTarget.x)
                {
                    turnRight();
                }
                else
                {
                    turnLeft();
                }
            }
        }
        
        public function getSourceRole():BaseHero
        {
            return sourceRole;
        }
        
        override public function destroy():void
        {
            var bb:BaseBullet = null;
            if (bbdc)
            {
                bbdc.destroy();
            }
            if (curAddEffect)
            {
                curAddEffect.destroy();
                curAddEffect = null;
            }
            isReadyToDestroy = true;
            TweenMax.to(this, 1, {
                "alpha": 0,
                "onComplete": function (param1:BasePet):*
                {
                    if (param1.parent)
                    {
                        param1.parent.removeChild(param1);
                    }
                },
                "onCompleteParams": [this]
            });
            for each (var bullet:BaseBullet in magicBulletArray)
            {
                bullet.destroy();
            }
            magicBulletArray = [];
            if (sourceRole)
            {
                sourceRole.clearPet();
                sourceRole = null;
            }
        }
        
        protected function beforeSkill1Start():Boolean
        {
            return false;
        }
        
        protected function beforeSkill2Start():Boolean
        {
            return false;
        }
        
        protected function beforeSkill3Start():Boolean
        {
            return false;
        }
        
        protected function beforeSkill4Start():Boolean
        {
            return false;
        }
        
        protected function releSkill1():void
        {
        }
        
        protected function releSkill2():void
        {
        }
        
        protected function releSkill3():void
        {
        }
        
        protected function releSkill4():void
        {
        }
        
        protected function myIntelligence():void
        {
            if (curAddEffect)
            {
                if (curAddEffect.isCannotControlSkill())
                {
                    return;
                }
            }
            if (!curAttackTarget)
            {
                searchTarget();
                if (Number(timeCount) % gc.frameClips == 0)
                {
                    followSource();
                }
            }
            else if (curAttackTarget.isDead())
            {
                curAttackTarget = null;
            }
            else if (AUtils.GetDisBetweenTwoObj(this, curAttackTarget) >= 500)
            {
                curAttackTarget = null;
            }
            else if (!isBeAttacking() && !isAttacking())
            {
                if (Boolean(beforeSkill1Start()) && skillCD1[0] == 0)
                {
                    releSkill1();
                    skillCD1[0] = skillCD1[1];
                }
                else if (Boolean(beforeSkill2Start()) && skillCD2[0] == 0)
                {
                    releSkill2();
                    skillCD2[0] = skillCD2[1];
                }
                else if (Boolean(beforeSkill3Start()) && skillCD3[0] == 0)
                {
                    releSkill3();
                    skillCD3[0] = skillCD3[1];
                }
                else if (Boolean(beforeSkill4Start()) && skillCD4[0] == 0)
                {
                    releSkill4();
                    skillCD4[0] = skillCD4[1];
                }
                else if (Number(timeCount) % gc.frameClips == 0)
                {
                    if (AUtils.GetDisBetweenTwoObj(this, curAttackTarget) <= attackRange)
                    {
                        if (Math.random() <= attackRate)
                        {
                            normalHit();
                        }
                        else if (Math.random() < 0.3)
                        {
                            setStatic();
                        }
                        else
                        {
                            followTarget();
                        }
                    }
                    else
                    {
                        followTarget();
                    }
                }
            }
            
            if (gc.isSingleGame())
            {
                checkBuffSkill();
            }
            if (y - Number(sourceRole.y) > 5 * 60)
            {
                if (!isAttacking() && !isBeAttacking())
                {
                    jump();
                }
            }
            else if (Number(sourceRole.y) - y > 50)
            {
                if (!isAttacking() && !isBeAttacking())
                {
                    getDownStair();
                }
            }
        }
        
        protected function doPassive():void
        {
            cureHp(_petInfo.hpHeal);
            cureMp(_petInfo.mpHeal);
        }
        
        protected function checkBuffSkill():void
        {
            if (sxkbCount > 0)
            {
                --sxkbCount;
            }
            if (fsnlCount > 0)
            {
                --fsnlCount;
            }
            if (smjcCount > 0)
            {
                --smjcCount;
            }
            if (mfjcCount > 0)
            {
                --mfjcCount;
            }
            if (gjjcCount > 0)
            {
                --gjjcCount;
            }
            if (fyjcCount > 0)
            {
                --fyjcCount;
            }
            if (testCount > 0)
            {
                --testCount;
            }
            var _loc1_:* = 0;
            var _loc2_:* = 0;
            if (sxkbCount == 0 && Boolean(_petInfo.findHasStudySkill("sxkb")) && getMp() >= _petInfo.findPetUsedMagic("sxkb"))
            {
                if (curAddEffect)
                {
                    _loc2_ = Number(_petInfo.getPetHarmObj("sxkb").first);
                    _loc1_ = uint(_petInfo.getPetHarmObj("sxkb").second);
                    trace("嗜血狂暴--》skillValue:" + _loc2_ + ",totalTime:" + _loc1_);
                    curAddEffect.addEffects([{
                        "name": BaseAddEffect.PET_SXKB,
                        "time": _loc1_ * gc.frameClips,
                        "value": _loc2_
                    }]);
                }
                _petInfo.reduceMp(_petInfo.findPetUsedMagic("sxkb"));
                sxkbCount = 4320;
            }
            if (fsnlCount == 0 && Boolean(_petInfo.findHasStudySkill("fsnl")) && getMp() >= _petInfo.findPetUsedMagic("fsnl"))
            {
                if (curAddEffect)
                {
                    _loc2_ = Number(_petInfo.getPetHarmObj("fsnl").first);
                    _loc1_ = uint(_petInfo.getPetHarmObj("fsnl").second);
                    trace("法术能量--》skillValue:" + _loc2_ + ",totalTime:" + _loc1_);
                    curAddEffect.addEffects([{
                        "name": BaseAddEffect.PET_FSNL,
                        "time": _loc1_ * gc.frameClips,
                        "value": _loc2_
                    }]);
                }
                _petInfo.reduceMp(_petInfo.findPetUsedMagic("fsnl"));
                fsnlCount = 5400;
            }
            if (smjcCount == 0 && Boolean(_petInfo.findHasStudySkill("smjc")) && getMp() >= _petInfo.findPetUsedMagic("smjc"))
            {
                if (curAddEffect)
                {
                    _loc2_ = Number(_petInfo.getPetHarmObj("smjc").first);
                    _loc1_ = uint(_petInfo.getPetHarmObj("smjc").second);
                    trace("生命加成--》skillValue:" + _loc2_ + ",totalTime:" + _loc1_);
                    if (sourceRole)
                    {
                        sourceRole.curAddEffect.addEffects([{
                            "name": BaseAddEffect.PET_SMJC,
                            "time": _loc1_ * gc.frameClips,
                            "value": _loc2_
                        }]);
                    }
                }
                _petInfo.reduceMp(_petInfo.findPetUsedMagic("smjc"));
                smjcCount = 5400;
            }
            if (mfjcCount == 0 && Boolean(_petInfo.findHasStudySkill("mfjc")) && getMp() >= _petInfo.findPetUsedMagic("mfjc"))
            {
                if (curAddEffect)
                {
                    _loc2_ = Number(_petInfo.getPetHarmObj("mfjc").first);
                    _loc1_ = uint(_petInfo.getPetHarmObj("mfjc").second);
                    trace("魔法加成--》skillValue:" + _loc2_ + ",totalTime:" + _loc1_);
                    if (sourceRole)
                    {
                        sourceRole.curAddEffect.addEffects([{
                            "name": BaseAddEffect.PET_MFJC,
                            "time": _loc1_ * gc.frameClips,
                            "value": _loc2_
                        }]);
                    }
                }
                _petInfo.reduceMp(_petInfo.findPetUsedMagic("mfjc"));
                mfjcCount = 5400;
            }
            if (gjjcCount == 0 && Boolean(_petInfo.findHasStudySkill("gjjc")) && getMp() >= _petInfo.findPetUsedMagic("gjjc"))
            {
                if (curAddEffect)
                {
                    _loc2_ = Number(_petInfo.getPetHarmObj("gjjc").first);
                    _loc1_ = uint(_petInfo.getPetHarmObj("gjjc").second);
                    trace("攻击加成--》skillValue:" + _loc2_ + ",totalTime:" + _loc1_);
                    if (sourceRole)
                    {
                        sourceRole.curAddEffect.addEffects([{
                            "name": BaseAddEffect.PET_GJJC,
                            "time": _loc1_ * gc.frameClips,
                            "value": _loc2_
                        }]);
                    }
                }
                _petInfo.reduceMp(_petInfo.findPetUsedMagic("gjjc"));
                gjjcCount = 5400;
            }
            if (fyjcCount == 0 && Boolean(_petInfo.findHasStudySkill("fyjc")) && getMp() >= _petInfo.findPetUsedMagic("fyjc"))
            {
                if (curAddEffect)
                {
                    _loc2_ = Number(_petInfo.getPetHarmObj("fyjc").first);
                    _loc1_ = uint(_petInfo.getPetHarmObj("fyjc").second);
                    trace("防御加成--》skillValue:" + _loc2_ + ",totalTime:" + _loc1_);
                    if (sourceRole)
                    {
                        sourceRole.curAddEffect.addEffects([{
                            "name": BaseAddEffect.PET_FYJC,
                            "time": _loc1_ * gc.frameClips,
                            "value": _loc2_
                        }]);
                    }
                }
                _petInfo.reduceMp(_petInfo.findPetUsedMagic("fyjc"));
                fyjcCount = 5400;
            }
        }
        
        protected function getCriteValue(param1:Boolean):Boolean
        {
            var _loc2_:* = null;
            var _loc3_:Boolean = false;
            var _loc4_:Number = Number(NaN);
            if (param1)
            {
                _loc4_ = 0;
                if (curAddEffect)
                {
//                    _loc2_ = curAddEffect.getEffectByType(BaseAddEffect.PET_SXKB);
                    if (_loc2_)
                    {
                        trace("嗜血狂暴->暴击率:" + _loc2_.value);
                        _loc4_ += _loc2_.value;
                    }
                }
                if (_petInfo)
                {
                    _loc4_ += _petInfo.crit * 0.01;
                }
                if (Math.random() <= _loc4_)
                {
                    _loc3_ = true;
                }
            }
            else
            {
                _loc3_ = false;
            }
            return _loc3_;
        }
        
        protected function getMagicAddValue():uint
        {
            var _loc1_:* = null;
            var _loc2_:* = 0;
            if (curAddEffect)
            {
//                _loc1_ = curAddEffect.getEffectByType(BaseAddEffect.PET_FSNL);
                if (_loc1_)
                {
                    trace("法术能量->提升伤害:" + _loc1_.value);
                    _loc2_ = uint(_loc1_.value);
                }
            }
            return _loc2_;
        }
        
        protected function normalHit():void
        {
            
            faceToTarget();
            setAction("hit1");
        }
        
        protected function followTarget():void
        {
            if (x > curAttackTarget.x)
            {
                turnLeft();
            }
            else
            {
                turnRight();
            }
        }
        
        protected function followSource():void
        {
            if (AUtils.GetDisBetweenTwoObj(this, sourceRole) > followRange)
            {
                if (x > sourceRole.x)
                {
                    turnLeft();
                }
                else
                {
                    turnRight();
                }
            }
            else
            {
                setStatic();
            }
        }
        
        protected function addAoyiBuff():void
        {
            var _loc1_:FollowTargetBullet = new FollowTargetBullet("AoyiBuff");
            _loc1_.x = x;
            _loc1_.y = y;
            _loc1_.setOwner(this);
            _loc1_.setDirect(0);
            _loc1_.setDisable();
            _loc1_.setAction("null");
            gc.gameScene.addChild(_loc1_);
            magicBulletArray.push(_loc1_);
        }
        
        protected function searchTarget():void
        {
            for each (var obj:BaseObject in gc.pWorld.getMonsterArray())
            {
                if (AUtils.GetDisBetweenTwoObj(obj, this) <= searchRange)
                {
                    curAttackTarget = obj;
                    break;
                }
            }
        }
        
        protected function showHpSlip():void
        {
            if (!hpSlip)
            {
                return;
            }
            hpSlip.visible = true;
            hpSlip.alpha = 1;
            if (TweenMax.isTweening(hpSlip))
            {
                TweenMax.killTweensOf(hpSlip, true);
            }
            TweenMax.to(hpSlip, 2, {
                "alpha": 0,
                "onComplete": function (param1:Sprite):*
                {
                    if (param1 != null)
                    {
                        param1.visible = false;
                    }
                },
                "onCompleteParams": [hpSlip]
            });
        }
        
        protected function newHpSlip():void
        {
            hpSlip = new Sprite();
            hpSlip.x = -23;
            hpSlip.y = getCollideArea().top - 10;
            hpSlip.visible = false;
            addChild(hpSlip);
        }
        
        protected function drawPetHp():void
        {
            hpSlip.graphics.clear();
            hpSlip.alpha = 1;
            if (isDead())
            {
                return;
            }
            var rate:Number = getHp() / getHpMax();
            rate = rate < 0 ? 0 : rate;
            hpSlip.graphics.lineStyle(1.2, 0);
            hpSlip.graphics.drawRect(0, 5, 50, 5);
            hpSlip.graphics.beginFill(0xFF0000);
            if (getBBDC().getDirect() == 0)
            {
                hpSlip.graphics.drawRect(0, 5, 50 * rate, 5);
            }
            else if (getBBDC().getDirect() == 1)
            {
                hpSlip.graphics.drawRect(50 - 50 * rate, 5, 50 * rate, 5);
            }
            hpSlip.graphics.endFill();
        }
        
        protected function hurtBaseEffectRate():Number
        {
            var _loc2_:* = undefined;
            var _loc1_:Number = 1;
            if (curAddEffect)
            {
//                _loc2_ = curAddEffect.getEffectByType(BaseAddEffect.MAGIC_FLOWER_ADDBUFF);
                if (_loc2_)
                {
                    if (_petInfo)
                    {
                        _loc1_ = 1 + _loc2_.value;
                    }
                }
            }
            return _loc1_;
        }
        
        private function countSkillCD():void
        {
            if (skillCD1[0] > 0)
            {
                if (skillCD1[0]-- <= 0)
                {
                    skillCD1[0] = 0;
                }
            }
            if (skillCD2[0] > 0)
            {
                if (skillCD2[0]-- <= 0)
                {
                    skillCD2[0] = 0;
                }
            }
            if (skillCD3[0] > 0)
            {
                if (skillCD3[0]-- <= 0)
                {
                    skillCD3[0] = 0;
                }
            }
            if (skillCD4[0] > 0)
            {
                if (skillCD4[0]-- <= 0)
                {
                    skillCD4[0] = 0;
                }
            }
        }
        
        private function clearWaitFromParentArray(param1:Array, param2:Array):void
        {
            var _loc3_:* = undefined;
            var _loc4_:int = 0;
            var _loc5_:int = 0;
            while (param1.length > 0)
            {
                _loc3_ = param1.shift();
                if ((_loc4_ = param2.indexOf(_loc3_)) != -1)
                {
                    param2.splice(_loc4_, 1);
                }
                _loc5_++;
            }
        }
    }
}
